package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.admin.Analysis;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AnalysisMapper extends BaseMapper<Analysis> {
    @Select("select sum(num_registered) from tb_analysis_by_day")
    Integer queryCumulativeUsers();

    @Select("SELECT sum(num_active) FROM tb_analysis_by_day WHERE DATEDIFF(record_date,NOW())<=0 AND DATEDIFF(record_date,NOW())>-30")
    Integer actionEndMonth();
    @Select("SELECT sum(num_active) FROM tb_analysis_by_day WHERE DATEDIFF(record_date,NOW())<=0 AND DATEDIFF(record_date,NOW())>-7")
    Integer actionEndWeek();
    /**
     *统计今日用户新增数量
     */
    @Select("select num_registered FROM tb_analysis_by_day WHERE record_date=#{record_date}")
    Integer queryByTypeAndLogTime(@Param("record_date") String logTime);

    /**
     * 登录数量
     *
     */
    @Select("select num_login FROM tb_analysis_by_day WHERE record_date=#{record_date}")
    Integer queryByLogTime(String record_date);


    /**
     *
     * 查询今日活跃用户
     */
    @Select("SELECT num_active FROM tb_analysis_by_day WHERE record_date=#{today}")
    Integer queryNumActive(String todayStr);


}
